package com.platform.module.dao.mapper;

import com.platform.module.dao.entity.TmInviteUserBetInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 代理等级用户下注流水记录 Mapper 接口
 * </p>
 *
 * @author ZM
 * @since 2025-01-09
 */
public interface TmInviteUserBetInfoMapper extends BaseMapper<TmInviteUserBetInfo> {

    @Select("select sum(balance) from tm_invite_user_bet_info where user_id = #{userId} and TO_DAYS(bill_date) = TO_DAYS(#{now})")
    BigDecimal sumBalanceByUserIdAndBillDate(Long userId, LocalDate now);

    @Select("select sum(balance) from tm_invite_user_bet_info where user_id = #{userId} and bill_date between #{cumulativeStartTime} and #{cumulativeExpiredTime}")
    BigDecimal sumBalanceByUserIdAndBillDateBetween(Long userId, LocalDateTime cumulativeStartTime, LocalDateTime cumulativeExpiredTime);
}
